From: Matt Fleming Date: Mon, 14 Mar 2016 10:33:01 +0000 (+0000) Subject: x86/mm/pat: Fix boot crash when 1GB pages are not supported by cpu X-Git-Tag: archive/raspbian/4.9.13-1+rpi1~28 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com//styles.css/%22http:/www.example.com/styles.css?a=commitdiff_plain;h=a818f5544afe8f99790a55e1e6ed74f00cb51cfe;p=linux-4.9.git x86/mm/pat: Fix boot crash when 1GB pages are not supported by cpu Scott reports that with the new separate EFI page tables he's seeing the following error on boot, caused by setting reserved bits in the page table structures (fault code is PF_RSVD | PF_PROT), swapper/0: Corrupted page table at address 17b102020 PGD 17b0e5063 PUD 1400000e3 Bad pagetable: 0009 [#1] SMP On first inspection the PUD is using a 1GB page size (_PAGE_PSE) and looks fine but that's only true if support for 1GB PUD pages ("pdpe1gb") is present in the cpu. Scott's Intel Celeron N2820 does not have that feature and so the _PAGE_PSE bit is reserved. Fix this issue by making the 1GB mapping code in conditional on "cpu_has_gbpages". This issue didn't come up in the past because the required mapping for the faulting address (0x17b102020) will already have been setup by the kernel in early boot before we got to efi_map_regions(), but we no longer use the standard kernel page tables during EFI calls. Reported-by: Scott Ashcroft Tested-by: Scott Ashcroft Cc: Ard Biesheuvel Cc: Ben Hutchings Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: "H. Peter Anvin" Cc: Linus Torvalds Cc: Maarten Lankhorst Cc: Matthew Garrett Cc: Peter Zijlstra Cc: Raphael Hertzog Cc: Roger Shimizu Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Signed-off-by: Matt Fleming Gbp-Pq: Topic bugfix/x86 Gbp-Pq: Name x86-mm-pat-fix-boot-crash-when-1gb-pages-are-not-supported.patch --- diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index a0fe62e3f4a3..1edbba8c56f1 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c @@ -1042,7 +1042,7 @@ static int populate_pud(struct cpa_data *cpa, unsigned long start, pgd_t *pgd, /* * Map everything starting from the Gb boundary, possibly with 1G pages */ - while (end - start >= PUD_SIZE) { + while (cpu_has_gbpages && end - start >= PUD_SIZE) { set_pud(pud, __pud(cpa->pfn << PAGE_SHIFT | _PAGE_PSE | massage_pgprot(pud_pgprot)));